home *** CD-ROM | disk | FTP | other *** search
- Path: tank.news.pipex.net!pipex!iol!not-for-mail
- From: goyra@iol.ie (David Byrden)
- Newsgroups: comp.lang.c++
- Subject: Re: Object constuction in function call.
- Date: 16 Mar 1996 11:25:56 GMT
- Organization: Ireland On-Line
- Message-ID: <4ie8g4$h9j@nuacht.iol.ie>
- References: <4icmqh$8g6@insosf1.netins.net> <4ie16n$pc1@sam.inforamp.net>
- NNTP-Posting-Host: joyce.iol.ie
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Randy Charles Morin (rmorin@inforamp.net) wrote:
- : In article <4icmqh$8g6@insosf1.netins.net>,
- : hhowe@trgnet.com (Harold Howe) wrote:
- : >class TCorners
- : > {
- : > public:
- : > int w,x,y,z;
- : > TCorners( int a, int b, int c, int d)
- : > { w=a; x=b; y=c; z=d;}
- : > }
- : >
- : > display_coordinates(TCorners(1,1,20,10));
- :
- : The TCorners that you declare in main() are destroyed when you exit main.
- : Thus at the end of your program you have 0 objects. Here's a procedure look
- : at what is happening.
- :
- : int main(void)
- : {
- : construct TCorners
- : display TCorners
- : construct TCorners
- : display TCorners
- : construct TCorners
- : display TCorners
- : destroy TCorners
- : destroy TCorners
- : destroy TCorners
- : };
- :
- : when the TCorners lose scope, then the destroy themselves.
- :
- : Agrivar
-
- Well, unfortunately, this explanation is wrong. The TCorners created
- as function parameters are "temporaries" and they have NO scope, for
- the simple reason that they have no names. Their lifetime is defined to
- end when you finish the STATEMENT in which they were created, not when
- you leave the current block.
-
- David
-
-